package com.frontyard.chatty.connection.impl;

import java.io.IOException;
import java.net.ServerSocket;
import java.util.HashMap;
import java.util.Map;

import com.frontyard.chatty.connection.ClientProcessor;
import com.frontyard.chatty.connection.ServerConnection;
import com.frontyard.chatty.connection.listener.ChattyServerListener;

public class ServerConnectionImpl implements ServerConnection {

    private ServerSocket socket;

    private ChattyServerListener listener;

    private Map<String, ClientProcessor> clients = new HashMap<String, ClientProcessor>();

    public void listen() {
        try {
            socket = new ServerSocket(CHATTY_PORT);
        } catch (IOException e) {
            listener.onError(e.getMessage());
            e.printStackTrace();
        }
    }

    public void setServerListener(ChattyServerListener listener) {
        this.listener = listener;
    }


}
